﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Services.Localization;
    using ICSharpCode.SharpZipLib.Zip;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.IO;
    using System.Web.Hosting;
    using System.Web.UI.WebControls;

    public class Export
    {
        private Hashtable CategoryListToHashTable(string CategoryList)
        {
            Hashtable hashtable2 = new Hashtable();
            if (CategoryList != "")
            {
                string[] strArray = Strings.Split(CategoryList, ",", -1, CompareMethod.Binary);
                int upperBound = strArray.GetUpperBound(0);
                for (int i = 0; i <= upperBound; i++)
                {
                    if (!hashtable2.ContainsKey(strArray[i]))
                    {
                        hashtable2.Add(strArray[i], strArray[i]);
                    }
                }
            }
            return hashtable2;
        }

        public string ExportDocs(int PortalID, string strBackupFile)
        {
            IEnumerator enumerator;
            ProductController controller = new ProductController();
            Hashtable hashtable = new Hashtable();
            ArrayList productDocExportList = controller.GetProductDocExportList(PortalID);
            try
            {
                enumerator = productDocExportList.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_ProductDocInfo current = (NB_Store_ProductDocInfo) enumerator.Current;
                    if (!hashtable.ContainsValue(current.DocPath))
                    {
                        hashtable.Add(current.DocID, current.DocPath);
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            if (this.ZipHashTable(hashtable, strBackupFile) > 0)
            {
                return strBackupFile;
            }
            return "";
        }

        public string ExportImages(int PortalID, string strBackupFile, string CategoryList)
        {
            NB_Store_CategoriesInfo category;
            IEnumerator enumerator;
            ProductController controller2 = new ProductController();
            Hashtable hashtable2 = new Hashtable();
            CategoryController controller = new CategoryController();
            Hashtable hashtable = this.CategoryListToHashTable(CategoryList);
            ArrayList productImageExportList = controller2.GetProductImageExportList(PortalID);
            try
            {
                enumerator = productImageExportList.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_ProductImageInfo current = (NB_Store_ProductImageInfo) enumerator.Current;
                    if (!hashtable2.ContainsValue(current.ImagePath))
                    {
                        if (hashtable.Count == 0)
                        {
                            hashtable2.Add(current.ImageID, current.ImagePath);
                        }
                        else
                        {
                            IEnumerator enumerator2;
                            try
                            {
                                enumerator2 = hashtable.Keys.GetEnumerator();
                                while (enumerator2.MoveNext())
                                {
                                    string expression = Conversions.ToString(enumerator2.Current);
                                    if ((Versioned.IsNumeric(expression) && !hashtable2.ContainsKey(current.ImageID)) && controller2.IsInCategory(current.ProductID, Conversions.ToString(Conversions.ToInteger(expression))))
                                    {
                                        hashtable2.Add(current.ImageID, current.ImagePath);
                                    }
                                }
                            }
                            finally
                            {
                                if (enumerator2 is IDisposable)
                                {
                                    (enumerator2 as IDisposable).Dispose();
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            if (hashtable.Count == 0)
            {
                IEnumerator enumerator3;
                productImageExportList = controller.GetCategories(PortalID, SharedFunctions.GetCurrentCulture(), -1, true, true);
                try
                {
                    enumerator3 = productImageExportList.GetEnumerator();
                    while (enumerator3.MoveNext())
                    {
                        category = (NB_Store_CategoriesInfo) enumerator3.Current;
                        if ((category.ImageURL != "") && !hashtable2.ContainsValue(HostingEnvironment.MapPath(category.ImageURL)))
                        {
                            hashtable2.Add("CAT" + category.CategoryID.ToString(), HostingEnvironment.MapPath(category.ImageURL));
                        }
                    }
                }
                finally
                {
                    if (enumerator3 is IDisposable)
                    {
                        (enumerator3 as IDisposable).Dispose();
                    }
                }
            }
            else
            {
                IEnumerator enumerator4;
                try
                {
                    enumerator4 = hashtable.Keys.GetEnumerator();
                    while (enumerator4.MoveNext())
                    {
                        string str3 = Conversions.ToString(enumerator4.Current);
                        if (Versioned.IsNumeric(str3))
                        {
                            category = controller.GetCategory(Conversions.ToInteger(str3), SharedFunctions.GetCurrentCulture());
                            if ((category.ImageURL != "") && !hashtable2.ContainsValue(HostingEnvironment.MapPath(category.ImageURL)))
                            {
                                hashtable2.Add("CAT" + category.CategoryID.ToString(), HostingEnvironment.MapPath(category.ImageURL));
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator4 is IDisposable)
                    {
                        (enumerator4 as IDisposable).Dispose();
                    }
                }
            }
            if (this.ZipHashTable(hashtable2, strBackupFile) > 0)
            {
                return strBackupFile;
            }
            return "";
        }

        public string ExportOrders(int PortalID, bool ArchivedOnly, string strBackupFile)
        {
            string str;
            try
            {
                ArrayList ordersExportList;
                IEnumerator enumerator;
                string strData = "";
                FileObj obj2 = new FileObj();
                LocaleCollection validLocales = SharedFunctions.GetValidLocales();
                OrderController controller = new OrderController();
                strData = strData + "<root version=\"1.0\">" + "<orders>";
                if (ArchivedOnly)
                {
                    ordersExportList = controller.GetOrdersExportList(PortalID, 0x4b);
                }
                else
                {
                    ordersExportList = controller.GetOrdersExportList(PortalID, -1);
                }
                try
                {
                    enumerator = ordersExportList.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        NB_Store_OrdersInfo current = (NB_Store_OrdersInfo) enumerator.Current;
                        strData = strData + this.GetOrderXML(current);
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                strData = strData + "</orders>" + "</root>";
                obj2.SaveTextToFile(strData, strBackupFile, "");
                str = strBackupFile;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                str = "";
                ProjectData.ClearProjectError();
            }
            return str;
        }

        public string ExportProducts(int PortalId, string strBackupFile, bool blnExpOrders, string CategoryList)
        {
            string str;
            try
            {
                ArrayList ordersExportList;
                IEnumerator enumerator;
                string strData = "";
                FileObj obj2 = new FileObj();
                ProductController controller2 = new ProductController();
                OrderController controller = new OrderController();
                LocaleCollection validLocales = SharedFunctions.GetValidLocales();
                strData = strData + "<root version=\"1.0\">" + "<products>";
                try
                {
                    enumerator = validLocales.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        IEnumerator enumerator2;
                        string lang = Conversions.ToString(enumerator.Current);
                        strData = strData + "<" + lang + ">";
                        ordersExportList = controller2.GetProductExportList(PortalId, lang, false, CategoryList);
                        try
                        {
                            enumerator2 = ordersExportList.GetEnumerator();
                            while (enumerator2.MoveNext())
                            {
                                NB_Store_ProductsInfo current = (NB_Store_ProductsInfo) enumerator2.Current;
                                strData = strData + this.GetProductXML(current);
                            }
                        }
                        finally
                        {
                            if (enumerator2 is IDisposable)
                            {
                                (enumerator2 as IDisposable).Dispose();
                            }
                        }
                        strData = strData + "</" + lang + ">";
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                strData = (strData + "</products>") + this.GetCategoriesXML(PortalId, CategoryList) + this.GetTaxXML(PortalId);
                if (blnExpOrders)
                {
                    IEnumerator enumerator3;
                    strData = strData + "<orders>";
                    ordersExportList = controller.GetOrdersExportList(PortalId, -1);
                    try
                    {
                        enumerator3 = ordersExportList.GetEnumerator();
                        while (enumerator3.MoveNext())
                        {
                            NB_Store_OrdersInfo objOInfo = (NB_Store_OrdersInfo) enumerator3.Current;
                            strData = strData + this.GetOrderXML(objOInfo);
                        }
                    }
                    finally
                    {
                        if (enumerator3 is IDisposable)
                        {
                            (enumerator3 as IDisposable).Dispose();
                        }
                    }
                    strData = strData + "</orders>";
                }
                strData = strData + "</root>";
                obj2.SaveTextToFile(strData, strBackupFile, "");
                str = strBackupFile;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                str = "";
                ProjectData.ClearProjectError();
            }
            return str;
        }

        public string ExportShipping(int PortalId, string strBackupFile)
        {
            string str;
            try
            {
                string strData = "";
                FileObj obj2 = new FileObj();
                ProductController controller = new ProductController();
                LocaleCollection validLocales = SharedFunctions.GetValidLocales();
                strData = (strData + "<root version=\"1.0\">") + this.GetShippingXML(PortalId) + "</root>";
                obj2.SaveTextToFile(strData, strBackupFile, "");
                str = strBackupFile;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                str = "";
                ProjectData.ClearProjectError();
            }
            return str;
        }

        public string GetCategoriesXML(int PortalId, string CategoryList)
        {
            IEnumerator enumerator;
            string str2 = "";
            CategoryController controller = new CategoryController();
            LocaleCollection validLocales = SharedFunctions.GetValidLocales();
            Hashtable hashtable = this.CategoryListToHashTable(CategoryList);
            str2 = str2 + "<categories>";
            try
            {
                enumerator = validLocales.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IEnumerator enumerator2;
                    string lang = Conversions.ToString(enumerator.Current);
                    str2 = str2 + "<" + lang + ">";
                    ArrayList categories = controller.GetCategories(PortalId, lang);
                    try
                    {
                        enumerator2 = categories.GetEnumerator();
                        while (enumerator2.MoveNext())
                        {
                            NB_Store_CategoriesInfo current = (NB_Store_CategoriesInfo) enumerator2.Current;
                            if (hashtable.Count == 0)
                            {
                                str2 = str2 + XmlUtils.Serialize(current);
                            }
                            else if (hashtable.ContainsKey(current.CategoryID.ToString()))
                            {
                                str2 = str2 + XmlUtils.Serialize(current);
                            }
                        }
                    }
                    finally
                    {
                        if (enumerator2 is IDisposable)
                        {
                            (enumerator2 as IDisposable).Dispose();
                        }
                    }
                    str2 = str2 + "</" + lang + ">";
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</categories>");
        }

        public string GetOrderXML(NB_Store_OrdersInfo objOInfo)
        {
            IEnumerator enumerator;
            string str2 = "";
            OrderController controller = new OrderController();
            str2 = (str2 + "<O>") + XmlUtils.Serialize(objOInfo) + "<BA>";
            NB_Store_AddressInfo orderAddress = controller.GetOrderAddress(objOInfo.BillingAddressID);
            if (orderAddress != null)
            {
                str2 = str2 + XmlUtils.Serialize(orderAddress);
            }
            str2 = str2 + "</BA>" + "<SA>";
            orderAddress = controller.GetOrderAddress(objOInfo.ShippingAddressID);
            if (orderAddress != null)
            {
                str2 = str2 + XmlUtils.Serialize(orderAddress);
            }
            str2 = str2 + "</SA>" + "<OD>";
            ArrayList orderDetailList = controller.GetOrderDetailList(objOInfo.OrderID);
            try
            {
                enumerator = orderDetailList.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_OrderDetailsInfo current = (NB_Store_OrderDetailsInfo) enumerator.Current;
                    str2 = str2 + XmlUtils.Serialize(current);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</OD>" + "</O>");
        }

        public string GetOrderXML(int OrderID)
        {
            NB_Store_OrdersInfo order = new OrderController().GetOrder(OrderID);
            return this.GetOrderXML(order);
        }

        public string GetProductXML(NB_Store_ProductsInfo objPInfo)
        {
            IEnumerator enumerator;
            IEnumerator enumerator2;
            IEnumerator enumerator3;
            IEnumerator enumerator4;
            IEnumerator enumerator5;
            IEnumerator enumerator6;
            string str2 = "";
            ProductController controller = new ProductController();
            str2 = (str2 + "<P>") + XmlUtils.Serialize(objPInfo) + "<M>";
            ArrayList productImageList = controller.GetModelList(objPInfo.PortalID, objPInfo.ProductID, objPInfo.Lang, true);
            try
            {
                enumerator = productImageList.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_ModelInfo current = (NB_Store_ModelInfo) enumerator.Current;
                    str2 = str2 + XmlUtils.Serialize(current);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            str2 = str2 + "</M>" + "<I>";
            productImageList = controller.GetProductImageList(objPInfo.ProductID, objPInfo.Lang);
            try
            {
                enumerator2 = productImageList.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    NB_Store_ProductImageInfo info5 = (NB_Store_ProductImageInfo) enumerator2.Current;
                    str2 = str2 + XmlUtils.Serialize(info5);
                }
            }
            finally
            {
                if (enumerator2 is IDisposable)
                {
                    (enumerator2 as IDisposable).Dispose();
                }
            }
            str2 = str2 + "</I>" + "<D>";
            productImageList = controller.GetProductDocList(objPInfo.ProductID, objPInfo.Lang);
            try
            {
                enumerator3 = productImageList.GetEnumerator();
                while (enumerator3.MoveNext())
                {
                    NB_Store_ProductDocInfo info = (NB_Store_ProductDocInfo) enumerator3.Current;
                    str2 = str2 + XmlUtils.Serialize(info);
                }
            }
            finally
            {
                if (enumerator3 is IDisposable)
                {
                    (enumerator3 as IDisposable).Dispose();
                }
            }
            str2 = str2 + "</D>" + "<C>";
            productImageList = controller.GetCategoriesAssigned(objPInfo.ProductID);
            try
            {
                enumerator4 = productImageList.GetEnumerator();
                while (enumerator4.MoveNext())
                {
                    NB_Store_ProductCategoryInfo info6 = (NB_Store_ProductCategoryInfo) enumerator4.Current;
                    str2 = str2 + XmlUtils.Serialize(info6);
                }
            }
            finally
            {
                if (enumerator4 is IDisposable)
                {
                    (enumerator4 as IDisposable).Dispose();
                }
            }
            str2 = str2 + "</C>" + "<R>";
            productImageList = controller.GetProductRelatedArray(objPInfo.PortalID, objPInfo.ProductID, objPInfo.Lang, -1, true);
            try
            {
                enumerator5 = productImageList.GetEnumerator();
                while (enumerator5.MoveNext())
                {
                    NB_Store_ProductRelatedInfo info7 = (NB_Store_ProductRelatedInfo) enumerator5.Current;
                    str2 = str2 + XmlUtils.Serialize(info7);
                }
            }
            finally
            {
                if (enumerator5 is IDisposable)
                {
                    (enumerator5 as IDisposable).Dispose();
                }
            }
            str2 = str2 + "</R>" + "<options>";
            productImageList = controller.GetOptionList(objPInfo.ProductID, objPInfo.Lang);
            try
            {
                enumerator6 = productImageList.GetEnumerator();
                while (enumerator6.MoveNext())
                {
                    IEnumerator enumerator7;
                    NB_Store_OptionInfo info3 = (NB_Store_OptionInfo) enumerator6.Current;
                    str2 = str2 + "<O>";
                    str2 = str2 + XmlUtils.Serialize(info3);
                    str2 = str2 + "<OV>";
                    ArrayList optionValueList = controller.GetOptionValueList(info3.OptionID, objPInfo.Lang);
                    try
                    {
                        enumerator7 = optionValueList.GetEnumerator();
                        while (enumerator7.MoveNext())
                        {
                            NB_Store_OptionValueInfo info4 = (NB_Store_OptionValueInfo) enumerator7.Current;
                            str2 = str2 + XmlUtils.Serialize(info4);
                        }
                    }
                    finally
                    {
                        if (enumerator7 is IDisposable)
                        {
                            (enumerator7 as IDisposable).Dispose();
                        }
                    }
                    str2 = str2 + "</OV>";
                    str2 = str2 + "</O>";
                }
            }
            finally
            {
                if (enumerator6 is IDisposable)
                {
                    (enumerator6 as IDisposable).Dispose();
                }
            }
            return (str2 + "</options>" + "</P>");
        }

        public string GetProductXML(int ProductID, string Lang)
        {
            NB_Store_ProductsInfo product = new ProductController().GetProduct(ProductID, Lang);
            if (product != null)
            {
                return this.GetProductXML(product);
            }
            return "";
        }

        public string GetSettingsTextXML(int PortalId)
        {
            return this.GetSettingsTextXML(PortalId, null, null);
        }

        public string GetSettingsTextXML(int PortalId, CheckBoxList chkList, Hashtable LanguageList)
        {
            IEnumerator enumerator;
            string str2 = "";
            SettingsController controller2 = new SettingsController();
            OrderController controller = new OrderController();
            str2 = str2 + "<settingstext>";
            ArrayList list = controller2.GetSettingsTexts(PortalId, "", true, "");
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_SettingsTextInfo current = (NB_Store_SettingsTextInfo) enumerator.Current;
                    if (chkList == null)
                    {
                        str2 = str2 + "<" + current.SettingName + " Lang=\"" + current.Lang.Trim() + "\" CtrlType=\"" + current.CtrlType + "\" GroupRef=\"" + current.GroupRef + "\" HostOnly=\"" + Conversions.ToString(current.HostOnly) + "\"><![CDATA[" + current.SettingText + "]]></" + current.SettingName + ">";
                    }
                    else if ((chkList.Items.FindByValue(current.SettingName) != null) && (chkList.Items.FindByValue(current.SettingName).Selected & LanguageList.Contains(current.Lang.Trim())))
                    {
                        str2 = str2 + "<" + current.SettingName + " Lang=\"" + current.Lang.Trim() + "\" CtrlType=\"" + current.CtrlType + "\" GroupRef=\"" + current.GroupRef + "\" HostOnly=\"" + Conversions.ToString(current.HostOnly) + "\"><![CDATA[" + current.SettingText + "]]></" + current.SettingName + ">";
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</settingstext>");
        }

        public string GetSettingsXML(int PortalId)
        {
            return this.GetSettingsXML(PortalId, null, null);
        }

        public string GetSettingsXML(int PortalId, CheckBoxList chkList, Hashtable LanguageList)
        {
            IEnumerator enumerator;
            string str2 = "";
            SettingsController controller2 = new SettingsController();
            OrderController controller = new OrderController();
            str2 = str2 + "<settings>";
            ArrayList list = controller2.GetSettingList(PortalId, "", true, "");
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_SettingsInfo current = (NB_Store_SettingsInfo) enumerator.Current;
                    if (chkList == null)
                    {
                        str2 = str2 + "<" + current.SettingName + " Lang=\"" + current.Lang.Trim() + "\" CtrlType=\"" + current.CtrlType + "\" GroupRef=\"" + current.GroupRef + "\" HostOnly=\"" + Conversions.ToString(current.HostOnly) + "\"><![CDATA[" + current.SettingValue + "]]></" + current.SettingName + ">";
                    }
                    else if ((chkList.Items.FindByValue(current.SettingName) != null) && (chkList.Items.FindByValue(current.SettingName).Selected & LanguageList.Contains(current.Lang.Trim())))
                    {
                        str2 = str2 + "<" + current.SettingName + " Lang=\"" + current.Lang.Trim() + "\" CtrlType=\"" + current.CtrlType + "\" GroupRef=\"" + current.GroupRef + "\" HostOnly=\"" + Conversions.ToString(current.HostOnly) + "\"><![CDATA[" + current.SettingValue + "]]></" + current.SettingName + ">";
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</settings>");
        }

        public string GetShippingXML(int PortalId)
        {
            IEnumerator enumerator;
            string str2 = "";
            ShipController controller = new ShipController();
            LocaleCollection validLocales = SharedFunctions.GetValidLocales();
            str2 = str2 + "<shipping>";
            ArrayList shippingMethodList = controller.GetShippingMethodList(PortalId);
            try
            {
                enumerator = shippingMethodList.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IEnumerator enumerator2;
                    NB_Store_ShippingMethodInfo current = (NB_Store_ShippingMethodInfo) enumerator.Current;
                    str2 = str2 + "<method>";
                    str2 = str2 + XmlUtils.Serialize(current);
                    str2 = str2 + "<rate>";
                    ArrayList list = controller.GetShippingRateList(PortalId, "", "", "", current.ShipMethodID);
                    try
                    {
                        enumerator2 = list.GetEnumerator();
                        while (enumerator2.MoveNext())
                        {
                            NB_Store_ShippingRatesInfo info = (NB_Store_ShippingRatesInfo) enumerator2.Current;
                            str2 = str2 + XmlUtils.Serialize(info);
                        }
                    }
                    finally
                    {
                        if (enumerator2 is IDisposable)
                        {
                            (enumerator2 as IDisposable).Dispose();
                        }
                    }
                    str2 = str2 + "</rate>";
                    str2 = str2 + "</method>";
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</shipping>");
        }

        public string GetSQLReports(int PortalID)
        {
            IEnumerator enumerator;
            string str2 = "";
            SQLReportController controller = new SQLReportController();
            ArrayList list2 = controller.GetSQLAdminReportList(PortalID, true, "");
            if (list2.Count <= 0)
            {
                return str2;
            }
            str2 = str2 + "<SQLReports>";
            try
            {
                enumerator = list2.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IEnumerator enumerator2;
                    IEnumerator enumerator3;
                    NB_Store_SQLReportInfo current = (NB_Store_SQLReportInfo) enumerator.Current;
                    str2 = str2 + "<SQLReport>";
                    str2 = str2 + XmlUtils.Serialize(current);
                    str2 = str2 + "<SQLReportParams>";
                    ArrayList sQLReportParamList = controller.GetSQLReportParamList(current.ReportID);
                    try
                    {
                        enumerator2 = sQLReportParamList.GetEnumerator();
                        while (enumerator2.MoveNext())
                        {
                            NB_Store_SQLReportParamInfo info = (NB_Store_SQLReportParamInfo) enumerator2.Current;
                            str2 = str2 + XmlUtils.Serialize(info);
                        }
                    }
                    finally
                    {
                        if (enumerator2 is IDisposable)
                        {
                            (enumerator2 as IDisposable).Dispose();
                        }
                    }
                    str2 = str2 + "</SQLReportParams>";
                    str2 = str2 + "<SQLReportXSL>";
                    sQLReportParamList = controller.GetSQLReportXSLList(current.ReportID);
                    try
                    {
                        enumerator3 = sQLReportParamList.GetEnumerator();
                        while (enumerator3.MoveNext())
                        {
                            NB_Store_SQLReportXSLInfo info3 = (NB_Store_SQLReportXSLInfo) enumerator3.Current;
                            str2 = str2 + XmlUtils.Serialize(info3);
                        }
                    }
                    finally
                    {
                        if (enumerator3 is IDisposable)
                        {
                            (enumerator3 as IDisposable).Dispose();
                        }
                    }
                    str2 = str2 + "</SQLReportXSL>";
                    str2 = str2 + "</SQLReport>";
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</SQLReports>");
        }

        public string GetStatusXML()
        {
            IEnumerator enumerator;
            string str2 = "";
            SettingsController controller2 = new SettingsController();
            OrderController controller = new OrderController();
            str2 = str2 + "<status>";
            ArrayList orderStatusList = controller.GetOrderStatusList("");
            try
            {
                enumerator = orderStatusList.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_OrderStatusInfo current = (NB_Store_OrderStatusInfo) enumerator.Current;
                    str2 = str2 + "<ID" + current.OrderStatusID.ToString() + " Lang=\"" + current.Lang + "\" ListOrder=\"" + Conversions.ToString(current.ListOrder) + "\"><![CDATA[" + current.OrderStatusText + "]]></ID" + current.OrderStatusID.ToString() + ">";
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</status>");
        }

        public string GetTaxXML(int PortalId)
        {
            IEnumerator enumerator;
            string str2 = "";
            TaxController controller = new TaxController();
            LocaleCollection validLocales = SharedFunctions.GetValidLocales();
            str2 = str2 + "<tax>";
            ArrayList list = controller.GetTaxRatesList(PortalId, "", "", "");
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_TaxRatesInfo current = (NB_Store_TaxRatesInfo) enumerator.Current;
                    str2 = str2 + XmlUtils.Serialize(current);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (str2 + "</tax>");
        }

        private int ZipHashTable(Hashtable list, string ZipFileName)
        {
            int level = 0;
            string str2 = Guid.NewGuid().ToString();
            FileStream baseOutputStream = null;
            baseOutputStream = File.Create(ZipFileName);
            ZipOutputStream zipFile = null;
            try
            {
                zipFile = new ZipOutputStream(baseOutputStream);
                zipFile.SetLevel(level);
                IDictionaryEnumerator enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    DictionaryEntry current = (DictionaryEntry) enumerator.Current;
                    string path = Conversions.ToString(current.Value);
                    if (File.Exists(path))
                    {
                        FileSystemUtils.AddToZip(ref zipFile, path, Path.GetFileName(path), "");
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
                return 0;
            }
            finally
            {
                if (zipFile != null)
                {
                    long length = zipFile.Length;
                    zipFile.Finish();
                    zipFile.Close();
                }
            }
            return -1;
        }
    }
}

